package com.lcj.dr.controller;

import com.github.pagehelper.PageInfo;
import com.lcj.common.util.Result;
import com.lcj.dr.controller.form.DriverLockDownForm;
import com.lcj.dr.db.pojo.DriverLockdownEntity;
import com.lcj.dr.service.DriverLockDownService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;

@RestController
@RequestMapping("/lockdown")
@Tag(name = "DriverLockDownController", description = "司机封禁管理Web接口")
public class DriverLockDownController {

    @Resource
    private DriverLockDownService driverLockDownService;

    @PostMapping("/add")
    @Operation(description = "新增禁闭信息")
    public Result add(@RequestBody @Valid DriverLockDownForm form) {
        Integer rows = driverLockDownService.add(form);
        return Result.ok().put("rows", rows);
    }

    @PostMapping("/delete")
    @Operation(description = "删除禁闭信息")
    public Result delete(@RequestBody @Valid DriverLockDownForm form) {
        Integer rows = driverLockDownService.delete(form);
        return Result.ok().put("rows", rows);
    }

    @PostMapping("/update")
    @Operation(description = "更新禁闭信息")
    public Result update(@RequestBody @Valid DriverLockDownForm form) {
        Integer rows = driverLockDownService.update(form);
        return Result.ok().put("rows", rows);
    }

    @PostMapping("/get")
    @Operation(description = "查询禁闭信息")
    public Result get(@RequestBody @Valid DriverLockDownForm form) {
        DriverLockdownEntity res = driverLockDownService.get(form);
        return Result.ok().put("result", res);
    }

    @PostMapping("/list")
    @Operation(description = "查询禁闭信息列表")
    public Result list(@RequestBody @Valid DriverLockDownForm form) {
        PageInfo<DriverLockdownEntity> list = driverLockDownService.list(form);
        return Result.ok().put("result", list);
    }

}
